<?php
if($home_user['user_type'] == 1) {
    $sql = 'SELECT * FROM '.FDB::table('wogu_user_shop').' WHERE uid='.$home_user['uid'];
    $shopinfo = FDB::fetchFirst($sql);

    // 好评、中评、差评
    $sql = 'SELECT COUNT(*) AS num FROM '.FDB::table('wogu_order').' WHERE shopid='.$home_user['uid'] . ' AND flag=2 AND grade=0';
    $r = FDB::fetchFirst($sql);
    $num_hao = $r['num'];
    $sql = 'SELECT COUNT(*) AS num FROM '.FDB::table('wogu_order').' WHERE shopid='.$home_user['uid'] . ' AND flag=2 AND grade=1';
    $r = FDB::fetchFirst($sql);
    $num_zhong = $r['num'];
    $sql = 'SELECT COUNT(*) AS num FROM '.FDB::table('wogu_order').' WHERE shopid='.$home_user['uid'] . ' AND flag=2 AND grade=2';
    $r = FDB::fetchFirst($sql);
    $num_cha = $r['num'];
}

$sql = 'SELECT * FROM '.FDB::table('article').' WHERE anli=0 AND flag=0 ORDER BY comment_count DESC LIMIT 5';
$arts = FDB::fetchAll($sql);
$sql = 'SELECT * FROM '.FDB::table('article').' WHERE anli=1 AND flag=0 ORDER BY comment_count DESC LIMIT 5';
$anlis = FDB::fetchAll($sql);

if(empty($_FANWE['cache']['medals'])) {
    Cache::getInstance()->loadCache('medals');
}
?>

<style type="text/css">
.art_list {}
.art_list li {height: 75px;}
.art_list li .art_content {margin-left: 5px;width: 110px; overflow: hidden;}
.art_clear {clear:both;}
.art_item div {float: left;}
</style>

<div class="user_right">
    <div class="user_side">
        <div class="i_avatar">
            <div class="j_img">
                <span class="j_img_vip">
                    <img width="80" height="80" src="{avatar $home_user['avatar'] b}" />
                </span>
            </div>
            <div class="j_name">
                <p>
                    <span style="font-weight:bold;">{$home_user['user_name']}</span>
                    {if !$home_user['realname_shop']}
                    <a href="/settings.php?action=realname">V认证</a>
                    {/if}
                </p>
                {if $home_user['user_type'] == 1 && $home_user['v2'] > 0}
                <p>
                    <?php $medal = $_FANWE['cache']['medals']['all'][$home_user['v2']]; ?>
                    <img src="{$medal['small_img']}" height="25" alt="{$medal['desc']}" title="{$medal['desc']}">
                    <!-- <a href="{u medal/u uid=$home_uid}" target="_blank"><img src="{$medal['small_img']}" height="25" alt="{$medal['desc']}" title="{$medal['desc']}"></a> -->
                </p>
                {else}
                <p>未认证</p>
                {/if}
            </div>
            <br class="g_clear" />
        </div>
        <div class="i_profile">
            <h3><b>{$home_user['user_name']}</b></h3>
            {if $home_user['uid'] == $_FANWE['uid']}<h5>余额：{$home_user['rmb_yu']}元</h5>{/if}
            <p><a href="http://hunlishu.com/{$home_user['name']}" style="color:#0a8cd2;">http://hunlishu.com/{$home_user['name']}</a></p>
            {if $home_user['user_type'] == 0}
            <p>{$home_user['introduce']}</p>
            {else}
            <p>
                {if $home_user['user_type'] == 1}
                {if $home_user['uid'] ==1}{else}<span title="已缴纳{$shopinfo['bzj']}元保证金">保证金：<span style="color: {if $shopinfo['bzj']==1000}green{elseif $shopinfo['bzj']>=3000}#FFCC00{else}#000{/if};font-weight: bold;">{$shopinfo['bzj']}元</span></span>{/if}<br/>
                <table width="180">
                    <tr style="background-color: #CCCCCC;">
                        <td align="center" style="color: #fff;">好评</td>
                        <!-- <td align="center" style="color: #fff;">中评</td> -->
                        <td align="center" style="color: #fff;">差评</td>
                    </tr>
                    <tr>
                        <td align="center"><a href="/article.php?action=comments&uid={$home_user['uid']}&type=0" style="color:red;">{$num_hao}</a></td>
                        <!-- <td align="center"><a href="/article.php?action=comments&uid={$home_user['uid']}&type=1" style="color:red;">{$num_zhong}</a></td> -->
                        <td align="center"><a href="/article.php?action=comments&uid={$home_user['uid']}&type=2" style="color:red;">{$num_cha}</a></td>
                    </tr>
                </table>
                {else}
                <span title="共获得{$home_user['zan_num']}个赞">赞:<b style="color:blue;">{$home_user['zan_num']}个</b></span>
                <span title="号召力{$home_user['hzl_num']}">号召力:<b style="color:blue;">{$home_user['hzl_num']}</b></span>
                <span title="经验值{$home_user['jy_num']}">经验:<b style="color:blue;">{$home_user['jy_num']}</b></span>
                {/if}
            </p>
            {/if}
            <a href="/wxmessage.php?action=index" class="j_edit" title="我的微信">我的微信</a>
            <!-- <a href="{u u/coupon}" class="j_edit" title="送优惠券">送优惠券</a> -->
            {if $home_uid == $_FANWE['user']['uid']}<br/>
            <a href="{u settings/personal}" class="j_edit">编辑个人资料</a>
            {else}
            <a href="/wxmessage.php?action=index&uid={$home_uid}&uname={$home_user['user_name']}" class="j_edit" title="发送消息">发送消息</a>
            {/if}
        </div>
    </div>
    <div class="user_rightbox">
        <div class="i_tt">
            <h3>热门案例</h3>
        </div>
        <div class="i_warp">
            <ul class="art_list">
                <!--{loop $anlis $anli}-->
                <li class="art_item">
                    <div class="art_img"><img src="{$anli['img']}" width="70" height="46" /></div>
                    <div class="art_content">
                        <a href="/article.php?action=show&id={$anli['id']}">{$anli['title']}</a>
                        <p>赞:{$anli['zai_num']}</p>
                    </div>
                    <div class="art_clear"></div>
                </li>
                <!--{/loop}-->
            </ul>
        </div>
    </div>
    <div class="user_rightbox">
        <div class="i_tt">
            <h3>热门经验</h3>
        </div>
        <div class="i_warp">
            <ul class="art_list">
                <!--{loop $arts $art}-->
                <li class="art_item">
                    <div class="art_img"><img src="{$art['img']}" width="70" height="46" /></div>
                    <div class="art_content">
                        <a href="/article.php?action=show&id={$art['id']}">{$art['title']}</a>
                        <p>赞:{$art['zai_num']}</p>
                    </div>
                    <div class="art_clear"></div>
                </li>
                <!--{/loop}-->
            </ul>
        </div>
    </div>
</div>

{if MODULE_NAME == 'u'}
<div class="i_notice2">
    <div class="j_title">公告栏</div>
    <div class="j_list">
        <ul>
             <li><a href="#"><span style="color:red;">婚礼款项建设银行冻结监管</span></a></li>
             <li><a href="#"><span style="color:red;">真实新人评价（新人凭婚宴发票进行评价）</span></a></li>
             <li><a href="#"><span style="color:red;">没有中间商赚差价</span></a></li>
        </ul>
    </div>
</div>
<div class="huoguojun2" id="huoguojun"><a href="/list.php?action=robot"><img src="/public/v1/img/huoguojun.png"></a></div>
{/if}

<script>
$(function() {
    var body_width = 960;
    body_width = $.browser.msie && $.browser.version == "6.0" ? 950 : 953;
    $("#back2top").css("left",Math.floor(($(window).width()-body_width)/2) + body_width + 5 + "px");

    $(window).resize(function(){
        var resize_width = Math.floor(($(window).width()-body_width)/2);
			if(resize_width > 10)
				backtop.css("left",resize_width + body_width + 5 + "px");
    });
});


</script>